﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QUrl>
#include <QtWebKit>
#include <QWebPage>
#include <QWebElement>
#include <QWebFrame>
#include <QWebElementCollection>
#include <QString>
#include <QFile>
#include <QTextStream>
#include <QCheckBox>
#include <QDebug>
#include <QHBoxLayout>
#include <QLabel>
#include <QShortcut>
#include <QSet>
#include <QModelIndexList>
#include <QTime>
#include <QRegExp>
#include <QClipboard>
#pragma execution_character_set("UTF-8")

static QString TeamWin[3]={"主胜","平局","客胜"};
static QString oddsaddr=QString("http://op1.win007.com/oddslist/");
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QShortcut *key1=new QShortcut(QKeySequence(Qt::Key_Q),this);
    connect(key1,SIGNAL(activated()),this,SLOT(on_pushButton_1_clicked()));
    QShortcut *key2=new QShortcut(QKeySequence(Qt::Key_W),this);
    connect(key2,SIGNAL(activated()),this,SLOT(on_pushButton_2_clicked()));
    QShortcut *key3=new QShortcut(QKeySequence(Qt::Key_E),this);
    connect(key3,SIGNAL(activated()),this,SLOT(on_pushButton_4_clicked()));
    QShortcut *key4=new QShortcut(QKeySequence(Qt::Key_R),this);
    connect(key4,SIGNAL(activated()),this,SLOT(on_pushButton_3_clicked()));
    QShortcut *key5=new QShortcut(QKeySequence(Qt::Key_5),this);
    connect(key5,SIGNAL(activated()),this,SLOT(on_pushButton_5_clicked()));

    file=new QFile("recordv5.txt");
    filelist=new QFile("recordList.txt");

    for(int i=0;i<3;i++)
    {
        TS[i]=0;
        PR[i]=0;
    }

}

MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::add_checkbox(QSet<QString> &Unicom)
{
    if(int((Unicom.size())/6))
    {
        int row=0;
        int colum=0;
        for(int i=0;i<Unicom.size();i++)
        {
            QCheckBox *company=new QCheckBox(Unicom.toList()[i]);
            colum=i%6;
            ui->gridLayout_2->addWidget(company,row,colum);

            if(colum==5)
                row++;
        }
    }
}

void MainWindow::init()
{
    Webtext_1="";
    Webtext_2="";
    Webtext_3="";
    Webtext_4="";
    companys_1.clear();
    companys_2.clear();
    companys_3.clear();
    companys_4.clear();
    selectCompanys.clear();
    predictResult.clear();
    UniCompanys.clear();
    Vec.clear();
    for(int i=0;i<3;i++)
    {
        recordcount[i]=0;
        SUM[i]=0;
        TS[i]=0;
        PR[i]=0;
    }

    game_1.clear();
    game_2.clear();
    game_3.clear();
    game_4.clear();


}

void MainWindow::add_checkbox(QVector<QStringList> &companys_num)
{
    if(companys_num.size()>=30)
    {
        int row=0;
        int colum=0;
        for(int i=0;i<30;i++)
        {
            QCheckBox *company=new QCheckBox(companys_num[i][1]);
            colum=i%6;
            ui->gridLayout_2->addWidget(company,row,colum);
            if(colum==5)
                row++;
        }
    }
    else
    {
        if(int((companys_num.size())/6))
        {
            int row=0;
            int colum=0;
            for(int i=0;i<companys_num.size();i++)
            {
                QCheckBox *company=new QCheckBox(companys_num[i][1]);
                colum=i%6;
                ui->gridLayout_2->addWidget(company,row,colum);
                if(colum==5)
                    row++;
            }
        }
    }
}

QString MainWindow::getWebtext(QWebFrame *frame, QString searchlabel)
{
    QWebElement document = frame->documentElement();
    //QWebElement element = document.findFirst("table#oddsList_tab");//win007
    QWebElement element=document.findFirst(searchlabel);
    return element.toPlainText();
}

QVector<QStringList> MainWindow::getList(QString text)
{
    QVector<QStringList> company_num;
    QStringList percompany=text.split("\n");
    foreach (QString onecompany, percompany) {
        QStringList Rcompany=onecompany.split("\t");
        company_num.push_back(Rcompany);
    }
    return company_num;
}

QVector<float> MainWindow::getkali(QStringList company)
{
    QVector<float> kali;
    for(int i=0;i<4;i++)
        kali.push_back(company[i+8].toFloat());
    return kali;
}

void MainWindow::listshow(QVector<QVector<float> > game,QListView *listview,QHBoxLayout *listcount)
{
    QStringListModel* slm = new QStringListModel(this);
    QStringList* results = new QStringList();
    int num=1;
    int weight[]={-1,-1,-1,-1};
    for(int i=0;i<3;i++)
    {
        recordcount[i]=0;
    }

    //int count[3]={0,0,0};
    for(int a=0;a<2;a++)
        for(int b=0;b<2;b++)
            for(int c=0;c<2;c++)
                for(int d=0;d<2;d++)
                {
                    if(a==1)
                        weight[0]=1;
                    if(a==0)
                        weight[0]=-1;
                    if(b==1)
                        weight[1]=1;
                    if(b==0)
                        weight[1]=-1;
                    if(c==1)
                        weight[2]=1;
                    if(c==0)
                        weight[2]=-1;
                    if(d==1)
                        weight[3]=1;
                    if(d==0)
                        weight[3]=-1;
                    calSUM(weight,game);
                    if(SUM[0]>SUM[1] && SUM[0]>SUM[2])
                    {
                        results->append(QString("[%8] [主胜] [%1 %2 %3 %4] [%5 %6 %7]")
                                    .arg(weight[0])
                                    .arg(weight[1])
                                    .arg(weight[2])
                                    .arg(weight[3])
                                    .arg(SUM[0])
                                    .arg(SUM[1])
                                    .arg(SUM[2])
                                    .arg(num));
                        recordcount[0]++;
                        num++;
                        continue;
                    }
                    if(SUM[1]>SUM[0] && SUM[1]>SUM[2])
                    {
                        results->append(QString("[%8] [平局] [%1 %2 %3 %4] [%5 %6 %7]")
                                    .arg(weight[0])
                                    .arg(weight[1])
                                    .arg(weight[2])
                                    .arg(weight[3])
                                    .arg(SUM[0])
                                    .arg(SUM[1])
                                    .arg(SUM[2])
                                    .arg(num));
                        recordcount[1]++;
                        num++;
                        continue;
                    }
                    if(SUM[2]>SUM[0] && SUM[2]>SUM[1])
                    {
                        results->append(QString("[%8] [客胜] [%1 %2 %3 %4] [%5 %6 %7]")
                                    .arg(weight[0])
                                    .arg(weight[1])
                                    .arg(weight[2])
                                    .arg(weight[3])
                                    .arg(SUM[0])
                                    .arg(SUM[1])
                                    .arg(SUM[2])
                                    .arg(num));
                        recordcount[2]++;
                        num++;
                        continue;
                    }
                    if(SUM[0]==SUM[1] || SUM[0]==SUM[2] || SUM[1]==SUM[2])
                    {
                        if(SUM[0]==SUM[1])
                        {
                            results->append(QString("[%8] [31] [%1 %2 %3 %4] [%5 %6 %7]")
                                        .arg(weight[0])
                                        .arg(weight[1])
                                        .arg(weight[2])
                                        .arg(weight[3])
                                        .arg(SUM[0])
                                        .arg(SUM[1])
                                        .arg(SUM[2])
                                        .arg(num));
                            num++;
                            continue;
                        }

                        if(SUM[0]==SUM[2])
                        {
                            results->append(QString("[%8] [30] [%1 %2 %3 %4] [%5 %6 %7]")
                                        .arg(weight[0])
                                        .arg(weight[1])
                                        .arg(weight[2])
                                        .arg(weight[3])
                                        .arg(SUM[0])
                                        .arg(SUM[1])
                                        .arg(SUM[2])
                                        .arg(num));
                            num++;
                            continue;
                        }

                        if(SUM[1]==SUM[2])
                        {
                            results->append(QString("[%8] [10] [%1 %2 %3 %4] [%5 %6 %7]")
                                        .arg(weight[0])
                                        .arg(weight[1])
                                        .arg(weight[2])
                                        .arg(weight[3])
                                        .arg(SUM[0])
                                        .arg(SUM[1])
                                        .arg(SUM[2])
                                        .arg(num));
                            num++;
                            continue;
                        }
                    }

                }
    slm->setStringList(*results);
    listview->setModel(slm);
    QLabel *c=new QLabel((QString("%1 %2 %3 | ").arg(recordcount[0]).arg(recordcount[1]).arg(recordcount[2])));
    listcount->addWidget(c);

    delete results;
}
void MainWindow::listshow(QVector<QVector<float> > game,QListView *listview)
{
    QStringListModel* slm = new QStringListModel(this);
    QStringList* results = new QStringList();
    int num=1;
    int weight[]={-1,-1,-1,-1};
    for(int i=0;i<3;i++)
    {
        recordcount[i]=0;
    }

    //int count[3]={0,0,0};
    for(int a=0;a<2;a++)
        for(int b=0;b<2;b++)
            for(int c=0;c<2;c++)
                for(int d=0;d<2;d++)
                {
                    if(a==1)
                        weight[0]=1;
                    if(a==0)
                        weight[0]=-1;
                    if(b==1)
                        weight[1]=1;
                    if(b==0)
                        weight[1]=-1;
                    if(c==1)
                        weight[2]=1;
                    if(c==0)
                        weight[2]=-1;
                    if(d==1)
                        weight[3]=1;
                    if(d==0)
                        weight[3]=-1;
                    calSUM(weight,game);
                    if(SUM[0]>SUM[1] && SUM[0]>SUM[2])
                    {
                        results->append(QString("[%8] [主胜] [%1 %2 %3 %4] [%5 %6 %7]")
                                    .arg(weight[0])
                                    .arg(weight[1])
                                    .arg(weight[2])
                                    .arg(weight[3])
                                    .arg(SUM[0])
                                    .arg(SUM[1])
                                    .arg(SUM[2])
                                    .arg(num));
                        recordcount[0]++;
                        num++;
                        continue;
                    }
                    if(SUM[1]>SUM[0] && SUM[1]>SUM[2])
                    {
                        results->append(QString("[%8] [平局] [%1 %2 %3 %4] [%5 %6 %7]")
                                    .arg(weight[0])
                                    .arg(weight[1])
                                    .arg(weight[2])
                                    .arg(weight[3])
                                    .arg(SUM[0])
                                    .arg(SUM[1])
                                    .arg(SUM[2])
                                    .arg(num));
                        recordcount[1]++;
                        num++;
                        continue;
                    }
                    if(SUM[2]>SUM[0] && SUM[2]>SUM[1])
                    {
                        results->append(QString("[%8] [客胜] [%1 %2 %3 %4] [%5 %6 %7]")
                                    .arg(weight[0])
                                    .arg(weight[1])
                                    .arg(weight[2])
                                    .arg(weight[3])
                                    .arg(SUM[0])
                                    .arg(SUM[1])
                                    .arg(SUM[2])
                                    .arg(num));
                        recordcount[2]++;
                        num++;
                        continue;
                    }
                    if(SUM[0]==SUM[1] || SUM[0]==SUM[2] || SUM[1]==SUM[2])
                    {
                        if(SUM[0]==SUM[1])
                        {
                            results->append(QString("[%8] [31] [%1 %2 %3 %4] [%5 %6 %7]")
                                        .arg(weight[0])
                                        .arg(weight[1])
                                        .arg(weight[2])
                                        .arg(weight[3])
                                        .arg(SUM[0])
                                        .arg(SUM[1])
                                        .arg(SUM[2])
                                        .arg(num));
                            num++;
                            continue;
                        }

                        if(SUM[0]==SUM[2])
                        {
                            results->append(QString("[%8] [30] [%1 %2 %3 %4] [%5 %6 %7]")
                                        .arg(weight[0])
                                        .arg(weight[1])
                                        .arg(weight[2])
                                        .arg(weight[3])
                                        .arg(SUM[0])
                                        .arg(SUM[1])
                                        .arg(SUM[2])
                                        .arg(num));
                            num++;
                            continue;
                        }

                        if(SUM[1]==SUM[2])
                        {
                            results->append(QString("[%8] [10] [%1 %2 %3 %4] [%5 %6 %7]")
                                        .arg(weight[0])
                                        .arg(weight[1])
                                        .arg(weight[2])
                                        .arg(weight[3])
                                        .arg(SUM[0])
                                        .arg(SUM[1])
                                        .arg(SUM[2])
                                        .arg(num));
                            num++;
                            continue;
                        }
                    }

                }
    slm->setStringList(*results);
    listview->setModel(slm);
    delete results;
}
void MainWindow::on_lineEdit_address_1_returnPressed()
{
    ui->webView_1->load(QUrl(ui->lineEdit_address_1->text()));
}
void MainWindow::on_lineEdit_address_2_returnPressed()
{
    ui->webView_2->load(QUrl(ui->lineEdit_address_2->text()));
}

void MainWindow::on_lineEdit_address_3_returnPressed()
{
    QString url=ui->lineEdit_address_3->text();
    if(url.endsWith("\n"))
    {
        url.resize(url.size()-1);
        ui->lineEdit_address_3->setText(url);
    }
    ui->webView_3->load(QUrl(url));
    ui->lineEdit_address_3->selectAll();
}


void MainWindow::on_webView_1_loadFinished(bool arg1)
{
    companys_1.clear();
    game_1.clear();
    Webtext_1=getWebtext(ui->webView_1->page()->mainFrame());
    companys_1=getList(Webtext_1);
    companys_1.pop_back();
    //add_checkbox(companys_1);
    if(!companys_1.isEmpty() && !companys_2.isEmpty() && !companys_3.isEmpty())
    {
        getUniCompanys();
        Vec=combinate(UniCompanys.size(),4);
        add_checkbox(UniCompanys);
    }


}

void MainWindow::on_webView_2_loadFinished(bool arg1)
{
    companys_2.clear();
    game_2.clear();
    Webtext_2=getWebtext(ui->webView_2->page()->mainFrame());
    companys_2=getList(Webtext_2);
    companys_2.pop_back();
    if(!companys_1.isEmpty() && !companys_2.isEmpty() && !companys_3.isEmpty())
    {
        getUniCompanys();
        Vec=combinate(UniCompanys.size(),4);
        add_checkbox(UniCompanys);
    }

}

void MainWindow::on_webView_3_loadFinished(bool arg1)
{
    companys_3.clear();
    game_3.clear();
        Webtext_3=getWebtext(ui->webView_3->page()->mainFrame());
    companys_3=getList(Webtext_3);
    companys_3.pop_back();
    getTeamName(ui->webView_3);
    date=QDate::currentDate();
    time=QTime::currentTime();

    getfenxiaddress(ui->webView_3);

    if(!companys_1.isEmpty() && !companys_2.isEmpty() && !companys_3.isEmpty())
    {
        getUniCompanys();
        Vec=combinate(UniCompanys.size(),4);
        add_checkbox(UniCompanys);
    }


}

void MainWindow::on_pushButton_1_clicked()
{
    selectCompanys.clear();
    game_1.clear();
    for(int i=0;i<ui->gridLayout_2->count();i++)
    {
        QCheckBox *child=(QCheckBox *)ui->gridLayout_2->itemAt(i)->widget();
        if(child->isChecked())
            selectCompanys.push_back(child->text());
    }//选择公司

    for(int i=0;i<selectCompanys.size();i++)
    {
        for(int j=0;j<companys_1.size();j++)
        {
            if(companys_1[j][1]==selectCompanys[i])
            {
                game_1.push_back(getkali(companys_1[j]));
                continue;
            }
        }
    }
    if(game_1.size()!=4)
    {
        ui->statusBar->showMessage("数据缺失");
        return;
    }

    listshow(game_1,ui->listView_1,ui->horizontalLayout_1);
    calcPosibily(ui->listView_1,ui->comboBox_1->currentText());
}

void MainWindow::on_pushButton_2_clicked()
{
    game_2.clear();
    for(int i=0;i<selectCompanys.size();i++)
    {
        for(int k=0;k<companys_2.size();k++)
        {
            if(companys_2[k][1]==selectCompanys[i])
            {
                game_2.push_back(getkali(companys_2[k]));
                continue;
            }
        }
    }

    if(game_2.size()!=4)
    {
        ui->statusBar->showMessage("数据缺失");
        return;
    }

    listshow(game_2,ui->listView_2,ui->horizontalLayout_2);
    calcPosibily(ui->listView_2,ui->comboBox_2->currentText());
}

void MainWindow::calSUM(int weight[], QVector<QVector<float> > game)
{
    float repay[4]={0,0,0,0};
    for(int i=0;i<4;i++)
        repay[i]=game[i][0]/100;
    SUM[0]=(weight[0]*(game[0][1]-repay[0])+weight[1]*(game[1][1]-repay[1])+weight[2]*(game[2][1]-repay[2])+weight[3]*(game[3][1]-repay[3]))*100;
    SUM[1]=(weight[0]*(game[0][2]-repay[0])+weight[1]*(game[1][2]-repay[1])+weight[2]*(game[2][2]-repay[2])+weight[3]*(game[3][2]-repay[3]))*100;
    SUM[2]=(weight[0]*(game[0][3]-repay[0])+weight[1]*(game[1][3]-repay[1])+weight[2]*(game[2][3]-repay[2])+weight[3]*(game[3][3]-repay[3]))*100;
}

void MainWindow::calcPosibily(QListView *listView,QString matchresult)
{
    QStringListModel* listModel=(QStringListModel *)listView->model();
    QStringList stringList=listModel->stringList();
    QVector<int> index;
    for(int i=0;i<stringList.size();i++)
    {
        QString tmpres=stringList[i];
        if(tmpres.contains(matchresult))
            index.push_back(i);
    }
///////////////////////////////////////////////////////////////////////
    QItemSelectionModel *selectModel=listView->selectionModel();
    for(int i=0;i<index.size();i++)
    {
        QItemSelection selection(listModel->index(index[i],0),listModel->index(index[i],0));
        selectModel->select(selection,QItemSelectionModel::Select);
    }

}

void MainWindow::predict(QListView *listView1, QListView *listView2)
{
    QItemSelectionModel *selectModel_1=listView1->selectionModel();
    QItemSelectionModel *selectModel_2=listView2->selectionModel();
    QItemSelectionModel *selectModel_4=ui->listView_4->selectionModel();
    QItemSelectionModel *selectModel_3=ui->listView_3->selectionModel();
    QStringListModel* listModel=(QStringListModel *)ui->listView_3->model();

    if(ui->comboBox->currentIndex()==0)
    {
        for(int i=0;i<16;i++)
        {
            if(selectModel_1->isRowSelected(i,QModelIndex()) && selectModel_2->isRowSelected(i,QModelIndex()) )
            {
                QItemSelection selection(listModel->index(i),listModel->index(i));
                selectModel_3->select(selection,QItemSelectionModel::Select);
            }
        }
    }
    if(ui->comboBox->currentIndex()==1)
    {
        for(int i=0;i<16;i++)
        {
            if(selectModel_1->isRowSelected(i,QModelIndex()) && selectModel_2->isRowSelected(i,QModelIndex()) && selectModel_4->isRowSelected(i,QModelIndex()) )
            {
                QItemSelection selection(listModel->index(i),listModel->index(i));
                selectModel_3->select(selection,QItemSelectionModel::Select);
            }
        }
    }
}

void MainWindow::getTeamName(QWebView* webview)
{
    QWebElement document = webview->page()->mainFrame()->documentElement();
    QWebElementCollection element = document.findAll("span.o_t_name");
    ui->lineEdit->setText(element[0].toPlainText()+"vs"+element[1].toPlainText());
    hometeam=element[0].toPlainText();
    guestteam=element[1].toPlainText();

    league=getWebtext(webview->page()->mainFrame(),"span.o_l_name2");

//    label1->setText(element[0].toPlainText());//hTeam
//    label2->setText(element[1].toPlainText());//gTeam

}

void MainWindow::getUniCompanys()
{
    QSet<QString> companyset_1;
    QSet<QString> companyset_2;
    QSet<QString> companyset_3;
    int a=companys_1.size();
    int b=companys_2.size();
    int c=companys_3.size();

    for(int i=0;i<a;i++)
        companyset_1.insert(companys_1[i][1]);
    for(int i=0;i<b;i++)
        companyset_2.insert(companys_2[i][1]);
    for(int i=0;i<c;i++)
        companyset_3.insert(companys_3[i][1]);

    QList<QString> maincompanylist;
    maincompanylist<<"威廉希尔(英国)"<<"立博(英国)"<<"澳门"
                  <<"bet 365(英国)"<<"bwin(奥地利)"<<"伟德(直布罗陀)"
                 <<"PinnacleSports(荷兰)"<<"Interwetten(塞浦路斯)"
                <<"Expekt([瑞典)"<<"SNAI(意大利)"<<"Gamebookers(安提瓜和巴布达)"
              <<"Betfair(英国)"<<"Coral(英国)"<<"IBCBET(哥斯达黎加)"
             <<"Nike(斯洛伐克)";


    UniCompanys=companyset_1.intersect(companyset_2);
    UniCompanys=UniCompanys.intersect(companyset_3);
    UniCompanys=UniCompanys.intersect(maincompanylist.toSet());

}

void MainWindow::getAvgOdds()
{
    float oddsum[3]={0,0,0};
    QList<QString> UniCompanyslist=UniCompanys.toList();
    for(int i=0;i<UniCompanyslist.size();i++)
    {
        for(int j=0;j<companys_3.size();j++)
        {
            if(companys_3[j][1]==UniCompanyslist[i])
            {
//                qDebug()<<UniCompanyslist[i];
                oddsum[0]+=QString(companys_3[j][2]).toFloat();
                oddsum[1]+=QString(companys_3[j][3]).toFloat();
                oddsum[2]+=QString(companys_3[j][4]).toFloat();
            }
        }
    }
    int fenmu=UniCompanyslist.size();
    avgodds.push_back(oddsum[0]/fenmu);
    avgodds.push_back(oddsum[1]/fenmu);
    avgodds.push_back(oddsum[2]/fenmu);
}

void MainWindow::getAvgKaili()
{
    QStringList avgFObj=getWebtext(ui->webView_3->page()->mainFrame(),QString("tr#avgFObj")).split("\t");
    QStringList avgRObj=getWebtext(ui->webView_3->page()->mainFrame(),QString("tr#avgRObj")).split("\t");
    for(int i=7;i<11;i++)
        avgkali.push_back(avgFObj[i].toFloat());
    avgkali.push_back(avgRObj[7].toFloat());



}

void MainWindow::on_pushButton_3_clicked()
{
    game_3.clear();
    for(int i=0;i<selectCompanys.size();i++)
    {
        for(int l=0;l<companys_3.size();l++)
        {
            if(companys_3[l][1]==selectCompanys[i])
            {
                game_3.push_back(getkali(companys_3[l]));
                continue;
            }
        }
    }

    if(game_3.size()!=4)
    {
        ui->statusBar->showMessage("数据缺失");
        return;
    }

    listshow(game_3,ui->listView_3,ui->horizontalLayout_3);

    //统计总预测
    predict(ui->listView_1,ui->listView_2);

}

void MainWindow::on_lineEdit_address_4_returnPressed()
{
    ui->webView_4->load(QUrl(ui->lineEdit_address_4->text()));
}

void MainWindow::on_webView_4_loadFinished(bool arg1)
{
    companys_4.clear();
    game_4.clear();
    Webtext_4=getWebtext(ui->webView_4->page()->mainFrame());
    companys_4=getList(Webtext_4);
    companys_4.pop_back();

}

void MainWindow::on_pushButton_4_clicked()
{
    game_4.clear();
    for(int i=0;i<selectCompanys.size();i++)
    {
        for(int k=0;k<companys_4.size();k++)
        {
            if(companys_4[k][1]==selectCompanys[i])
            {
                game_4.push_back(getkali(companys_4[k]));
                continue;
            }
        }
    }

    if(game_4.size()!=4)
    {
        ui->statusBar->showMessage("数据缺失");
        return;
    }

    listshow(game_4,ui->listView_4,ui->horizontalLayout_4);
    calcPosibily(ui->listView_4,ui->comboBox_3->currentText());
}

void MainWindow::on_lineEdit_address_3_textChanged(const QString &arg1)
{
    ui->lineEdit_address_1->setText(ui->lineEdit_address_3->text());
    ui->lineEdit_address_2->setText(ui->lineEdit_address_3->text());
    ui->lineEdit_address_4->setText(ui->lineEdit_address_3->text());
}

void MainWindow::on_pushButton_clicked()
{
    QVector<QVector<float> > game;
    for(int i=0;i<Vec.size();i++)
    {
        game.clear();
        for(int j=0;j<Vec[i].size();j++)
        {
            for(int l=0;l<companys_3.size();l++)
            {
                if(companys_3[l][1]==Vec[i][j])
                {
                    game.push_back(getkali(companys_3[l]));
                    continue;
                }
            }
        }
        writelist(Vec[i],game);
    }
}

void MainWindow::writelist(QStringList company,QVector<QVector<float> > game)
{
    QStringListModel* slm = new QStringListModel(this);
    QStringList* results = new QStringList();
    QTextStream ts(filelist);
    ts.setCodec("UTF-8");
    int num=1;
    int weight[]={-1,-1,-1,-1};
    for(int i=0;i<3;i++)
    {
        recordcount[i]=0;
    }

    //int count[3]={0,0,0};
    for(int a=0;a<2;a++)
        for(int b=0;b<2;b++)
            for(int c=0;c<2;c++)
                for(int d=0;d<2;d++)
                {
                    if(a==1)
                        weight[0]=1;
                    if(a==0)
                        weight[0]=-1;
                    if(b==1)
                        weight[1]=1;
                    if(b==0)
                        weight[1]=-1;
                    if(c==1)
                        weight[2]=1;
                    if(c==0)
                        weight[2]=-1;
                    if(d==1)
                        weight[3]=1;
                    if(d==0)
                        weight[3]=-1;
                    calSUM(weight,game);
                    if(SUM[0]>SUM[1] && SUM[0]>SUM[2])
                    {
                        results->append(QString("[%8] [主胜] [%1 %2 %3 %4] [%5 %6 %7]")
                                    .arg(weight[0])
                                    .arg(weight[1])
                                    .arg(weight[2])
                                    .arg(weight[3])
                                    .arg(SUM[0])
                                    .arg(SUM[1])
                                    .arg(SUM[2])
                                    .arg(num));
                        recordcount[0]++;
                        num++;
                        continue;
                    }
                    if(SUM[1]>SUM[0] && SUM[1]>SUM[2])
                    {
                        results->append(QString("[%8] [平局] [%1 %2 %3 %4] [%5 %6 %7]")
                                    .arg(weight[0])
                                    .arg(weight[1])
                                    .arg(weight[2])
                                    .arg(weight[3])
                                    .arg(SUM[0])
                                    .arg(SUM[1])
                                    .arg(SUM[2])
                                    .arg(num));
                        recordcount[1]++;
                        num++;
                        continue;
                    }
                    if(SUM[2]>SUM[0] && SUM[2]>SUM[1])
                    {
                        results->append(QString("[%8] [客胜] [%1 %2 %3 %4] [%5 %6 %7]")
                                    .arg(weight[0])
                                    .arg(weight[1])
                                    .arg(weight[2])
                                    .arg(weight[3])
                                    .arg(SUM[0])
                                    .arg(SUM[1])
                                    .arg(SUM[2])
                                    .arg(num));
                        recordcount[2]++;
                        num++;
                        continue;
                    }
                    if(SUM[0]==SUM[1] || SUM[0]==SUM[2] || SUM[1]==SUM[2])
                    {
                        if(SUM[0]==SUM[1])
                        {
                            results->append(QString("[%8] [31] [%1 %2 %3 %4] [%5 %6 %7]")
                                        .arg(weight[0])
                                        .arg(weight[1])
                                        .arg(weight[2])
                                        .arg(weight[3])
                                        .arg(SUM[0])
                                        .arg(SUM[1])
                                        .arg(SUM[2])
                                        .arg(num));
                            num++;
                            continue;
                        }

                        if(SUM[0]==SUM[2])
                        {
                            results->append(QString("[%8] [30] [%1 %2 %3 %4] [%5 %6 %7]")
                                        .arg(weight[0])
                                        .arg(weight[1])
                                        .arg(weight[2])
                                        .arg(weight[3])
                                        .arg(SUM[0])
                                        .arg(SUM[1])
                                        .arg(SUM[2])
                                        .arg(num));
                            num++;
                            continue;
                        }

                        if(SUM[1]==SUM[2])
                        {
                            results->append(QString("[%8] [10] [%1 %2 %3 %4] [%5 %6 %7]")
                                        .arg(weight[0])
                                        .arg(weight[1])
                                        .arg(weight[2])
                                        .arg(weight[3])
                                        .arg(SUM[0])
                                        .arg(SUM[1])
                                        .arg(SUM[2])
                                        .arg(num));
                            num++;
                            continue;
                        }
                    }

                }
    slm->setStringList(*results);
//    listview->setModel(slm);
//    QLabel *c=new QLabel((QString("%1 %2 %3 | ").arg(recordcount[0]).arg(recordcount[1]).arg(recordcount[2])));
//    listcount->addWidget(c);
    if(filelist->open(QFile::WriteOnly|QFile::Append))
    {
        ts<<"["<<company[0]<<" "<<company[1]<<" "<<company[2]<<" "<<company[3]<<"]"<<"\t";
        //ts<<"["<<recordcount[0]<<" "<<recordcount[1]<<" "<<recordcount[2]<<"]"<<"\n";
        ts<<recordcount[0]<<"\t"<<recordcount[1]<<"\t"<<recordcount[2]<<"\n";
    }

    filelist->close();
    delete results;
}

void MainWindow::isSelect(QListView *listView)
{
//    QTextStream ts(file);
//    ts.setCodec("UTF-8");
    QItemSelectionModel *listSelectModel=listView->selectionModel();
    QModelIndexList listSelected=listSelectModel->selectedRows();
//    if(file->open(QFile::WriteOnly|QFile::Append))
    {
        QSet<QString> set;
        for(int i=0;i<listSelected.size();i++)
        {
            QString temp=listSelected[i].data().toString();
            QStringList templist=temp.split(" ");

            set.insert(templist[1]);
//            ts<<templist[1]<<"\t";
//            predictResult<<templist[1];

            if(templist[1]=="[主胜]")
                TS[0]++;
            if(templist[1]=="[平局]")
                TS[1]++;
            if(templist[1]=="[客胜]")
                TS[2]++;
        }
        for(int i=0;i<set.size();i++)
        {
//            ts<<set[i]<<"\t";
//            predictResult<<set.toList().at(i);
            QList<QString> list=set.toList();
            if(list.at(i)=="[主胜]")
                PR[0]++;
            if(list.at(i)=="[平局]")
                PR[1]++;
            if(list.at(i)=="[客胜]")
                PR[2]++;
        }
//        ts<<"\n";
    }
//    file->close();
}

void MainWindow::getfenxiaddress(QWebView *webview)
{
    QString label3adr=ui->lineEdit_address_3->text();
    QString label1adr;
    QString label2adr;
    QWebElement document = webview->page()->mainFrame()->documentElement();
    QWebElement element = document.findFirst("a.nobg");
    QString tmp1=element.toOuterXml();
    QStringList tmp1list=tmp1.split("\"");
    label3adr=tmp1list[1];
    ui->lineEdit_address_5->setText(label3adr);
    on_lineEdit_address_5_returnPressed();
}

void MainWindow::handlefenxi(QWebView *webview)
{
    QWebElement document = webview->page()->mainFrame()->documentElement();
    QWebElement element = document.findFirst("div.t1p1");
    QString gametimetext=element.toPlainText();

    QRegExp rxdate("\\d{1,4}-\\d{1,2}-\\d{1,2}");
    int pos = gametimetext.indexOf(rxdate);
    if(pos>=0)
        datetext=rxdate.cap(0);
    QRegExp rxtime("\\d{1,2}:\\d{1,2}");
    pos = gametimetext.indexOf(rxtime);
    if(pos>=0)
        timetext=rxtime.cap(0);

    ui->lineEdit_4->setText(datetext+" "+timetext);


    document = webview->page()->mainFrame()->documentElement();
    element = document.findFirst("table#table_hn");
    QWebElementCollection collect=element.findAll("a");
    QStringList tmplistxml1=collect[1].toOuterXml().split("\"");
    QStringList tail1=tmplistxml1[1].split("/");
    QString addrtail1=tail1[4];
    ui->lineEdit_address_1->setText(oddsaddr+addrtail1);
    on_lineEdit_address_1_returnPressed();
    QString tmpplat1=element.toPlainText();
    QStringList tmpplatlist1=tmpplat1.split("\t");
    QString bifen1=tmpplatlist1[18];
    bifen1=bifen1.mid(0,bifen1.indexOf("("));
    QStringList bifenlist1=bifen1.split("-");

    if(bifenlist1[0].toInt()>bifenlist1[1].toInt())
        ui->comboBox_1->setCurrentIndex(0);
    if(bifenlist1[0].toInt()==bifenlist1[1].toInt())
        ui->comboBox_1->setCurrentIndex(1);
    if(bifenlist1[0].toInt()<bifenlist1[1].toInt())
        ui->comboBox_1->setCurrentIndex(2);

    element = document.findFirst("table#table_an");
    collect=element.findAll("a");
    QStringList tmplist2=collect[1].toOuterXml().split("\"");
    QStringList tail2=tmplist2[1].split("/");
    QString addrtail2=tail2[4];
    ui->lineEdit_address_2->setText(oddsaddr+addrtail2);
    on_lineEdit_address_2_returnPressed();
    QString tmpplat2=element.toPlainText();
    QStringList tmpplatlist2=tmpplat2.split("\t");
    QString bifen2=tmpplatlist2[18];
    bifen2=bifen2.mid(0,bifen2.indexOf("("));
    QStringList bifenlist2=bifen2.split("-");

    if(bifenlist2[0].toInt()>bifenlist2[1].toInt())
        ui->comboBox_2->setCurrentIndex(0);
    if(bifenlist2[0].toInt()==bifenlist2[1].toInt())
        ui->comboBox_2->setCurrentIndex(1);
    if(bifenlist2[0].toInt()<bifenlist2[1].toInt())
        ui->comboBox_2->setCurrentIndex(2);

    element = document.findFirst("table#table_v");
    collect=element.findAll("a");
    if(collect.count()>0)
    {
        QStringList tmplist3=collect[1].toOuterXml().split("\"");
        QStringList tail3=tmplist3[1].split("/");
        QString addrtail3=tail3[4];
        ui->lineEdit_address_4->setText(oddsaddr+addrtail3);
        on_lineEdit_address_4_returnPressed();
        QString tmpplat3=element.toPlainText();
        QStringList tmpplatlist3=tmpplat3.split("\t");
        QString bifen3=tmpplatlist3[18];
        bifen3=bifen3.mid(0,bifen3.indexOf("("));
        QStringList bifenlist3=bifen3.split("-");

        if(bifenlist3[0].toInt()>bifenlist3[1].toInt())
            ui->comboBox_3->setCurrentIndex(0);
        if(bifenlist3[0].toInt()==bifenlist3[1].toInt())
            ui->comboBox_3->setCurrentIndex(1);
        if(bifenlist3[0].toInt()<bifenlist3[1].toInt())
            ui->comboBox_3->setCurrentIndex(2);
    }

    element = document.findFirst("tr#tr_o_1_4");
    QString handicapfirst=element.toPlainText();
    if(!handicapfirst.isEmpty())
    {
        QStringList handicapfirstlist=handicapfirst.split("\t");
        ui->lineEdit_2->setText((QString("%1\t%2\t%3").arg(handicapfirstlist[9]).arg(handicapfirstlist[10]).arg(handicapfirstlist[11])));

        handif=QString("%1\t%2\t%3").arg(handicapfirstlist[9]).arg(handicapfirstlist[10]).arg(handicapfirstlist[11]);
    }
    else
    {
        element=document.findFirst("tr#tr_o_1_3");
        handicapfirst=element.toPlainText();
        QStringList handicapfirstlist=handicapfirst.split("\t");
        ui->lineEdit_2->setText((QString("%1\t%2\t%3").arg(handicapfirstlist[9]).arg(handicapfirstlist[10]).arg(handicapfirstlist[11])));

        handif=QString("%1\t%2\t%3").arg(handicapfirstlist[9]).arg(handicapfirstlist[10]).arg(handicapfirstlist[11]);
    }

    element = document.findFirst("tr#tr_o_2_4");
    QString handicaplast=element.toPlainText();
    if(!handicaplast.isEmpty())
    {
        QStringList handicaplastlist=handicaplast.split("\t");
        ui->lineEdit_3->setText((QString("%1\t%2\t%3").arg(handicaplastlist[8]).arg(handicaplastlist[9]).arg(handicaplastlist[10])));

        handil=QString("%1\t%2\t%3").arg(handicaplastlist[8]).arg(handicaplastlist[9]).arg(handicaplastlist[10]);
    }
    else
    {
        element=document.findFirst("tr#tr_o_2_3");
        handicaplast=element.toPlainText();
        QStringList handicaplastlist=handicaplast.split("\t");
        ui->lineEdit_2->setText((QString("%1\t%2\t%3").arg(handicaplastlist[8]).arg(handicaplastlist[9]).arg(handicaplastlist[10])));

        handil=QString("%1\t%2\t%3").arg(handicaplastlist[8]).arg(handicaplastlist[9]).arg(handicaplastlist[10]);
    }

    QClipboard *clipboard = QApplication::clipboard();
    clipboard->setText(datetext+" "+timetext+"\t"+ui->lineEdit_address_3->text()+"\t"+league+"\t"+hometeam+"vs"+guestteam+"\t"
                       +handif+"\t"+handil);
}

void MainWindow::on_pushButton_5_clicked()
{
    QTextStream ts(file);
    ts.setCodec("UTF-8");
    file->close();
    getAvgOdds();
    getAvgKaili();
    int eight[3]={0,0,0};
    if(file->open(QFile::WriteOnly|QFile::Append))
    {
        for(int i=0;i<Vec.size();i++)
        {
            QStringList selectedcom=Vec[i];
            game_1.clear();
            game_2.clear();
            game_3.clear();

            for(int l=0;l<selectedcom.size();l++)
            {
                for(int j=0;j<companys_1.size();j++)
                {
                    if(companys_1[j][1]==selectedcom[l])
                    {
                        game_1.push_back(getkali(companys_1[j]));
                        continue;
                    }
                }
            }
            listshow(game_1,ui->listView_1,ui->horizontalLayout_1);
            calcPosibily(ui->listView_1,ui->comboBox_1->currentText());

            for(int l=0;l<selectedcom.size();l++)
            {
                for(int j=0;j<companys_2.size();j++)
                {
                    if(companys_2[j][1]==selectedcom[l])
                    {
                        game_2.push_back(getkali(companys_2[j]));
                        continue;
                    }
                }
            }
            listshow(game_2,ui->listView_2,ui->horizontalLayout_2);
            calcPosibily(ui->listView_2,ui->comboBox_2->currentText());

            for(int l=0;l<selectedcom.size();l++)
            {
                for(int j=0;j<companys_3.size();j++)
                {
                    if(companys_3[j][1]==selectedcom[l])
                    {
                        game_3.push_back(getkali(companys_3[j]));
                        continue;
                    }
                }
            }
            listshow(game_3,ui->listView_3);
            predict(ui->listView_1,ui->listView_2);
//            ts<<"["<<selectedcom[0]<<selectedcom[1]<<selectedcom[2]<<selectedcom[3]<<"]"<<"\t";
//            ts<<"["<<recordcount[0]<<"|"<<recordcount[1]<<"|"<<recordcount[2]<<"]"<<"\t";
            if(recordcount[0]>=8)//home win
                eight[0]++;
            if(recordcount[1]>=8)//draw
                eight[1]++;
            if(recordcount[2]>=8)//away win
                eight[2]++;

//            eight[0]=recordcount[0];
//            eight[1]=recordcount[2];
//            eight[2]=recordcount[1];
            //file->close();
            isSelect(ui->listView_3);

        }

        //ui->lineEdit_4->setText(date.toString("yyyy年MMMdd日")+" "+time.toString("HH点m分"));
        //ui->lineEdit_5->setText((QString("%1\t%2\t%3\t%4\t%5\t%6").arg(TS[0]).arg(TS[1]).arg(TS[2]).arg(PR[0]).arg(PR[1]).arg(PR[2])));
        //QLineEdit *rr=new QLineEdit((QString("%4\t%5\t%6").arg(PR[0]).arg(PR[1]).arg(PR[2])));
        //ui->lineEdit_6->setText((QString("%1\t%3\t%2").arg(eight[0]).arg(eight[2]).arg(eight[1])));
        int tssum=TS[1]+TS[2]+TS[0];
        int prsum=PR[0]+PR[1]+PR[2];
        int TSEsum=tssum+eight[0]+eight[1]+eight[2];
        float predictvalues[6]={0,0,0,0,0,0};
        float prfloat[3]={0,0,0};
        for(int iz=0;iz<3;iz++)
        {
            predictvalues[iz]=(float)TS[iz]/tssum*100;
            predictvalues[iz+3]=(float)(TS[iz]+eight[iz])/TSEsum*100;
            prfloat[iz]=(float)PR[iz]/prsum*100;
        }

        ts<<"\n";
        QClipboard *clip=QApplication::clipboard();
        clip->setText(datetext+" "+timetext+"\t"+ui->lineEdit_address_3->text()+"\t"+league+"\t"+hometeam+"vs"+guestteam+"\t"
                      +handif+"\t"+handil+"\t"+QString("%1\t%2\t%3").arg(avgodds[0]).arg(avgodds[1]).arg(avgodds[2])+"\t"
                     +QString("%1\t%2\t%3").arg(prfloat[0]).arg(prfloat[1]).arg(prfloat[2])+"\t"+QString("%1\t%2\t%3\t%4\t%5\t%6").arg(predictvalues[0]).arg(predictvalues[1]).arg(predictvalues[2]).arg(predictvalues[3]).arg(predictvalues[4]).arg(predictvalues[5])
                     +"\t"+QString("%1\t%2\t%3").arg(eight[0]).arg(eight[1]).arg(eight[2])+"\t"+QString("%1\t%2\t%3\t%4\t%5\t%6").arg(bigsmall[0]).arg(bigsmall[1]).arg(bigsmall[2]).arg(bigsmall[3]).arg(bigsmall[4]).arg(bigsmall[5])+"\t"+(ui->lineEdit_goal->text()));
        if(ui->lineEdit_goal->text()=="")
        {
            if(datetext.isEmpty()||timetext.isEmpty())
                ts<<date.toString("yyyy年MMMdd日")<<" "<<time.toString("HH点m分")<<"\t"<<ui->lineEdit_address_3->text()<<"\t"<<league<<"\t"<<hometeam<<"vs"<<guestteam<<"\t"
                 <<handif<<"\t"<<handil<<"\t"<<avgodds[0]<<"\t"<<avgodds[1]<<"\t"<<avgodds[2]<<"\t"
                <<QString("%1\t%2\t%3").arg(prfloat[0]).arg(prfloat[1]).arg(prfloat[2])<<"\t"<<QString("%1\t%2\t%3\t%4\t%5\t%6").arg(predictvalues[0]).arg(predictvalues[1]).arg(predictvalues[2]).arg(predictvalues[3]).arg(predictvalues[4]).arg(predictvalues[5])
                <<"\t"<<QString("%1\t%2\t%3").arg(eight[0]).arg(eight[1]).arg(eight[2])<<"\t"<<QString("%1\t%2\t%3\t%4\t%5\t%6").arg(bigsmall[0]).arg(bigsmall[1]).arg(bigsmall[2]).arg(bigsmall[3]).arg(bigsmall[4]).arg(bigsmall[5]);
            else
                ts<<datetext<<" "<<timetext<<"\t"<<ui->lineEdit_address_3->text()<<"\t"<<league<<"\t"<<hometeam<<"vs"<<guestteam<<"\t"
                 <<handif<<"\t"<<handil<<"\t"<<avgodds[0]<<"\t"<<avgodds[1]<<"\t"<<avgodds[2]<<"\t"
                <<QString("%1\t%2\t%3").arg(prfloat[0]).arg(prfloat[1]).arg(prfloat[2])<<"\t"<<QString("%1\t%2\t%3\t%4\t%5\t%6").arg(predictvalues[0]).arg(predictvalues[1]).arg(predictvalues[2]).arg(predictvalues[3]).arg(predictvalues[4]).arg(predictvalues[5])
                <<"\t"<<QString("%1\t%2\t%3").arg(eight[0]).arg(eight[1]).arg(eight[2])<<"\t"<<QString("%1\t%2\t%3\t%4\t%5\t%6").arg(bigsmall[0]).arg(bigsmall[1]).arg(bigsmall[2]).arg(bigsmall[3]).arg(bigsmall[4]).arg(bigsmall[5]);

        }
        else
        {
            if(datetext.isEmpty()||timetext.isEmpty())
            ts<<date.toString("yyyy年MMMdd日")<<" "<<time.toString("HH点m分")<<"\t"<<ui->lineEdit_address_3->text()<<"\t"<<league<<"\t"<<hometeam<<"vs"<<guestteam<<"\t"
             <<handif<<"\t"<<handil<<"\t"<<avgodds[0]<<"\t"<<avgodds[1]<<"\t"<<avgodds[2]<<"\t"
            <<QString("%1\t%2\t%3").arg(prfloat[0]).arg(prfloat[1]).arg(prfloat[2])<<"\t"<<QString("%1\t%2\t%3\t%4\t%5\t%6").arg(predictvalues[0]).arg(predictvalues[1]).arg(predictvalues[2]).arg(predictvalues[3]).arg(predictvalues[4]).arg(predictvalues[5])
            <<"\t"<<QString("%1\t%2\t%3").arg(eight[0]).arg(eight[1]).arg(eight[2])<<"\t"<<QString("%1\t%2\t%3\t%4\t%5\t%6").arg(bigsmall[0]).arg(bigsmall[1]).arg(bigsmall[2]).arg(bigsmall[3]).arg(bigsmall[4]).arg(bigsmall[5])
            <<"\t"<<ui->lineEdit_goal->text();
            else
            ts<<datetext<<" "<<timetext<<"\t"<<ui->lineEdit_address_3->text()<<"\t"<<league<<"\t"<<hometeam<<"vs"<<guestteam<<"\t"
             <<handif<<"\t"<<handil<<"\t"<<avgodds[0]<<"\t"<<avgodds[1]<<"\t"<<avgodds[2]<<"\t"
            <<QString("%1\t%2\t%3").arg(prfloat[0]).arg(prfloat[1]).arg(prfloat[2])<<"\t"<<QString("%1\t%2\t%3\t%4\t%5\t%6").arg(predictvalues[0]).arg(predictvalues[1]).arg(predictvalues[2]).arg(predictvalues[3]).arg(predictvalues[4]).arg(predictvalues[5])
            <<"\t"<<QString("%1\t%2\t%3").arg(eight[0]).arg(eight[1]).arg(eight[2])<<"\t"<<QString("%1\t%2\t%3\t%4\t%5\t%6").arg(bigsmall[0]).arg(bigsmall[1]).arg(bigsmall[2]).arg(bigsmall[3]).arg(bigsmall[4]).arg(bigsmall[5])
            <<"\t"<<ui->lineEdit_goal->text();
        }

    }
    file->close();
    QApplication::quit();
}


QVector<QStringList> MainWindow::combinate(int n, int m)//n=UniCompanys.size(),m=4
{
    QVector<QStringList> SubVec;
    QStringList subcomps;
    QVector<int> index(n,0);
    //build 0-1 vector
    for(int i=0;i<m;i++)
    {
        index[i]=1;
    }
    bool has_next=true;
    while(has_next)
    {
        //get chosen
        int j=0;
        for(int i=0;i<n;i++)
        {
            if(index[i]==1)
                subcomps.push_back(UniCompanys.toList()[i]);
        }
        if(subcomps.size()==m)
            SubVec.push_back(subcomps);

        subcomps.clear();
        has_next=false;
        for(int i=0;i<n-1;i++)
        {
            if(index[i]==1 && index[i+1]==0)
            {
                index[i]=0;
                index[i+1]=1;

                int count=0;
                for(int j=0;j<i;j++)
                {
                    if(index[j]==1)
                        count++;
                }
                if(count<i)
                {
                    for(int j=0;j<count;j++)
                    {
                        index[j]=1;
                    }
                    for(int j=count;j<i;j++)
                    {
                        index[j]=0;
                    }
                }

                has_next=true;
                break;
            }
        }
    }

    return SubVec;
}

void MainWindow::on_webView_5_loadFinished(bool arg1)
{
    handlefenxi(ui->webView_5);
    QStringList temp1=getWebtext(ui->webView_5->page()->mainFrame(),QString("tr#tr_o_1_3")).split("\t");
    QStringList temp2=getWebtext(ui->webView_5->page()->mainFrame(),QString("tr#tr_o_2_3")).split("\t");
    for(int i=13;i<16;i++)
        bigsmall.push_back(temp1[i]);
    for(int i=12;i<15;i++)
        bigsmall.push_back(temp2[i]);
/*
    QTextStream ts(file);
    ts.setCodec("UTF-8");
    if(file->open(QFile::WriteOnly|QFile::Append))
    {
        ts<<"\n";
        ts<<QString("%1\t%2\t%3\t%4\t%5\t%6").arg(bigsmall[0]).arg(bigsmall[1]).arg(bigsmall[2]).arg(bigsmall[3]).arg(bigsmall[4]).arg(bigsmall[5]);
    }

*/
}

void MainWindow::on_lineEdit_address_5_returnPressed()
{
    ui->webView_5->load(QUrl(ui->lineEdit_address_5->text()));
}
